﻿using IMark.DAO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IMark
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                lnkXuHuongTimKiem.InnerHtml = GenerateSearch();
            }
        }

        private string GenerateSearch()
        {
            List<SAN_PHAM> ltSanPham = SanPhamModels.LaySanPhamMuaNhieu();
            StringBuilder str = new StringBuilder();
            for (int i = 0; i < ltSanPham.Count; i++)
            {
                if ((i + 1) == ltSanPham.Count)
                {
                    str.Append("<a href=\"TimKiem.aspx?Search=" + ltSanPham[i].TenSanPham + "\">" + ltSanPham[i].TenSanPham + "</a>");
                }
                else
                {
                    str.Append("<a href=\"TimKiem.aspx?Search=" + ltSanPham[i].TenSanPham + "\">" + ltSanPham[i].TenSanPham + "</a> | ");
                }
            }
            return str.ToString();
        }
    }
}